import Search from 'antd/es/input/Search';
import React from 'react';
import { AudioOutlined } from '@ant-design/icons';
import { message } from 'antd/es';
import { getUser } from '../../services/userServices';

class SearchUser extends React.PureComponent {
  constructor(props) {
    super(props);
  }

  suffix = (
    <AudioOutlined
      style={{
        fontSize: 16,
        color: '#1890ff',
      }}
    />
  );

  onSearch = async(values) => {
    try {
      const response = await getUser(values);
      const { data } = response;
      console.log(data);
      message.info('User searched successfully');
    } catch (error) {
      message.error(error.message || 'Failed to search user');
    }
  }

  render() {
    return (
      <>
        <Search
          placeholder="输入需要查找的用户id"
          enterButton="Search"
          size="large"
          suffix={this.suffix}
          onSearch={this.onSearch}
        />
      </>
    );
  }
}

export default SearchUser;
